package com.lagou.controller;


import com.lagou.pojo.Resume;
import com.lagou.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RequestMapping("/page")
@Controller
public class StaticController {

    @Autowired
    private ResumeService resumeService;

    @RequestMapping("/list.htm")
    public ModelAndView findAll(ModelAndView modelAndView) {
        final List<Resume> all = resumeService.findAll();
        modelAndView.addObject("data", all);
        modelAndView.setViewName("list");
        return modelAndView;
    }

    // 最终的展现页为 edit.jsp
    @RequestMapping("/edit.htm")
    public ModelAndView edit(Resume resume) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("data", resume);
        modelAndView.setViewName("edit");
        return modelAndView;
    }

    // 内部调用 "/edit.htm" 接口
    @RequestMapping("/add.htm")
    public ModelAndView add() {
        return this.edit(null);
    }

    @RequestMapping("/login.htm")
    public ModelAndView login(String name, String password) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("login");
        return modelAndView;
    }
}







































